class Solution:
    def reconstructMatrix(self, upper: int, lower: int, colsum: list) -> list:
        matrix = [[0 for _ in range(len(colsum))] for _ in range(2)]
        for i in range(len(colsum)):
            if colsum[i] == 2:
                matrix[0][i] = 1
                matrix[1][i] = 1
                upper -= 1
                lower -= 1
                continue
            if colsum[i] == 0:
                continue
            if upper >= lower:
                matrix[0][i] = 1
                upper -= 1
            else:
                matrix[1][i] = 1
                lower -= 1

        if upper != 0 or lower != 0:
            return []

        return matrix


if __name__ == '__main__':
    print(Solution().reconstructMatrix(upper=2, lower=3, colsum=[2, 2, 1, 1]))
